/*
 * @Author: 万仁杰、余文童
 * @Date: 2020-08-12 15:43:25
 * @LastEditTime: 2020-08-13 01:29:02
 * @LastEditors: Please set LastEditors
 * @Description: 获取商品细节信息控制器
 * @FilePath: \BackEnd\saleflower\src\main\java\com\wangwang\saleflower\controller\DetailController.java
 */
package com.wangwang.saleflower.controller;

import com.wangwang.saleflower.entity.ResultState;
import com.wangwang.saleflower.entity.ResultState.State;
import com.wangwang.saleflower.service.FlowerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/api")
public class DetailController {

    @Autowired
    private FlowerService detailService;

    @GetMapping("/product/detail")
    public ResultState selectFlowerList(@RequestParam(name = "fwnum") Integer fwnum){
        ResultState result;
        var flowerList = detailService.selectFlowerList(fwnum);
        if (flowerList == null) {
            result = ResultState.CreateResult(State.ERROR, null, "该商品不存在");
        } else {
            result = ResultState.CreateResult(State.SUCCESS, flowerList, "成功查找");
        }
        return result;
    }
}
